# -*-coding: utf-8 -*-
import sys

reload(sys)
sys.setdefaultencoding("utf-8")

'''
list = ['chi','得到','sdfsd']

for i in list:
    print i

list.sort()

for i in list:
    print i
'''
'''
# coding:utf-8
import time

列表和字典查找性能对比
'''
'''
testDict = {}
testList = []
for i in range(1000000):
    n = str(i)
    testDict[n] = i
    testList.append(n)

startTime = time.time()
if '1002213' in testDict:
    print 'yes'
print time.time()-startTime

startTime = time.time()
if '1002213' in testList:
    #print 'yes'
print time.time()-startTime
'''

'''
content = open('BaseConfig.cfg').read()
#Window下用记事本打开配置文件并修改保存后，编码为UNICODE
或UTF-8的文件的文件头
#会被相应的加上\xff\xfe（\xff\xfe）或\xef\xbb\xbf，
然后再传递给ConfigParser解析的时候会出错
#，因此解析之前，先替换掉
import re
content = open('BaseConfig.cfg').read()
content = re.sub(r"\xfe\xff","", content)
content = re.sub(r"\xff\xfe","", content)
content = re.sub(r"\xef\xbb\xbf","", content)
open('BaseConfig.cfg', 'w').write(content)

'''

#-*- coding: utf-8 -*-
#! /usr/bin/python

import datetime
import random


def logit(content, filename='makesnlog.txt'):
    '''
    逐行添加日志，每行一个回车
    头部是时间
    '''
    file = open(filename, 'a')
    try:
        timestr = datetime.datetime.now().strftime('%y-%m-%d %H:%M:%S')+': '
        file.write(timestr+content+'\r\n')
    finally:
        file.close()

print random.randint(1, 3)
print random.randint(1, 2)
